using System.Collections;
using System.Collections.Generic;
using QFramework;
using UnityEngine;

public class Dissolve : MonoBehaviour
{
        public Material Material;
        public static readonly int Color = Shader.PropertyToID("_Color");
        public static readonly int Fade = Shader.PropertyToID("_Fade");
        public Color DissolveColor;
        private void Start()
        {
            var material = Instantiate(Material);
            GetComponent<SpriteRenderer>().material = material;
            material.SetColor(Color,DissolveColor);
            ActionKit.Lerp(0, 1, 0.5F, (fade) =>
            {
                material.SetFloat(Fade, fade);
                this.LocalScale(0.1f + (1 - fade) * 0.5f);
            })
            .Start(this,()=>//动画完成后执行回调。
            {
                Destroy(material);//销毁复制的材质
                this.DestroyGameObjGracefully();//定义方法，“优雅地” 销毁当前游戏对象（可能包含延迟、事件通知等额外逻辑 ）。
            });
        }
    }

